#-------------------------------------------------------------------------------
# Name:        jocallback.py
# Purpose:      put the callback-functions here to let the modules call back
#                to the user-interface to update the status
#
# Author:      joris bollen
#
# Created:     01-03-2011
# Copyright:   (c) jobo 2011
# Licence:     license to code
#-------------------------------------------------------------------------------
#!/usr/bin/env python

##import main_startup
import wx

def setStatusBar(messagest, barnumberit, strictrefreshbo=False):
    callframe = wx.GetApp().GetTopWindow()
    callframe.sbar.SetStatusText(messagest, barnumberit)
    if strictrefreshbo:
        wx.GetApp().Yield(True)

def refreshGui():
    wx.GetApp().Yield(True)


# BELOW CODE IS EXPERIMENTAL AND UNDER CONSTRUCTION

def startProgressBar(titlest, messagest,  maxit):
    # under construction

##    maxit = 80
    callframe = wx.GetApp().GetTopWindow()

    mybar = wx.ProgressDialog(titlest,messagest, maximum = maxit,
##                           parent=self,
                           parent=callframe,
                           style = wx.PD_CAN_ABORT
                            | wx.PD_APP_MODAL
                            | wx.PD_ELAPSED_TIME
                            #| wx.PD_ESTIMATED_TIME
                            | wx.PD_REMAINING_TIME
                            )
##    mybar.Update()

def updateProgressBar(dialognamest, newcountit):
    # under construction
##    wx.GetTopLevelParent(window)


##    mydialog = wx.GetApp().GetTopWindow()
    mydialog = wx.GetTopLevelParent('mybar')
    print mydialog
    print mydialog.Name
##    curapp = wx.GetApp()
##    curbar = getattr(curapp,dialognamest)
    mydialog.Update(newcountit)


def endProgressBar(dialognamest):
    # under construction
    callframe = wx.GetApp().GetTopWindow()
    curbar = getattr(callframe,dialognamest)
    curbar.Destroy()





if __name__ == '__main__':
    pass
